export class Timer<T extends 'Timeout' | 'Interval'> {
  #name: T
  #id?: ReturnType<typeof globalThis[`set${T}`]>

  constructor(name: T){
    this.#name = name
  }

  run = (...args: Parameters<typeof globalThis[`set${T}`]>) => {
    this.#id = globalThis[`set${this.#name}`](...args as [any]) as any
  }

  stop = () => globalThis[`clear${this.#name}`](this.#id)
}